package its.opt.utils;

import its.opt.StatsLoader;
import its.opt.data.RoadDataManager;
import its.opt.program.Evaluator;
import its.opt.program.HeuristicEvaluator;
import its.opt.program.SimulationEvaluator;
import its.sim.SimulatorConfiguration;
import its.sim.stats.StatDataType;

public class EvaluationFunctionFactory {

	public static Evaluator getEvaluator(String[] args,
			SimulatorConfiguration conf, StatsLoader statsLoader) {

		Evaluator evaluator = null;

		if (conf.getEvalFun().equals("sim-max-avg")) {
			evaluator = new SimulationEvaluator(args);
		} else if (conf.getEvalFun().equals("heuristic")) {
			RoadDataManager manager = new RoadDataManager();

			manager.addConnections(statsLoader.getDataSet(StatDataType.ROUTE));
			manager.addDelayTimes(statsLoader.getDataSet(StatDataType.ROAD_DELAY));
			manager
					.addStopTimes(statsLoader.getDataSet(StatDataType.ROAD_STOP_TIMES));
			manager
					.addPassTimes(statsLoader.getDataSet(StatDataType.ROAD_PASS_TIMES));
			manager.addStopCount(statsLoader.getDataSet(StatDataType.ROAD_STOPS));

			evaluator = new HeuristicEvaluator(manager);
		}

		return evaluator;
	}
}
